#include "StdAfx.h"
#include <highgui.h>
#include "WebCam.h"
#include "..\..\lib\CCameraDS\CameraDS.h"


CWebCam::CWebCam(void)
{
    this->pCam = NULL;
}


CWebCam::~CWebCam(void)
{
    if (this->pCam != NULL)
    {
        delete pCam;
    }
}

void CWebCam::Initialize()
{
    if (!m_initialized)
    {
        this->pCam = new CCameraDS();
        this->pCam->OpenCamera(this->deviceId, false);
        m_initialized = true;
    }
    
   
}


IplImage* CWebCam::CaptureFrame()
{
    if (!this->m_initialized)
    {
        throw "camera is not initialized";
    }

    IplImage* frame = this->pCam->QueryFrame();
    return frame;

}

int CWebCam::GetCameraCount()
{
    return CCameraDS::CameraCount();
}